var data = [
  {
    field1: 'YH200123001',
    field2: '无水乙醇',
    field3: '50ml',
    field4: '瓶',
    field5: '100',
  }
]

function clickOperate(id, row) {
  var roleIds = row.roleIds;
  // 传值给click事件
  return "<a class='qn-check' onclick='checkDetail(`" + id + "`)'>查看</a>" +
      "<a class='qn-check' onclick='storage(`" + id + "`)'>入库</a>" +
      "<a class='qn-check' onclick='loss(`" + id + "`)'>损耗</a>" +
      "<a class='qn-check' onclick='use(`" + id + "`)'>领用</a>" ;
};

//查看详情
function checkDetail(id) {
   window.location.href="perishableProductDetail.html";
};

//入库
function storage(id) {
   $("#storage_modal").modal("show");
}

//损耗
function loss(id) {
   $("#loss_modal").modal("show");
}

//领用
function use(id) {
   $("#use_modal").modal("show");
}


/**
*批量删除
*/
function deleteEquipement(){
  var selects = $('#equipeMentTable').bootstrapTable('getSelections');  
  var ids = $.map(selects, function (row) {  
        return row.id;  
  });  

  if( ids && ids.length == 0) {
    showAlert(null,"请选择删除项");
    return;
  };

  showConfirm("提示","确定要删除选择项吗？",function(){
      $('#equipeMentTable').bootstrapTable('remove', {  
            field: 'id',  
            values: ids  
      });  
  });
};

/**
 * 根据条件查询
 */
function queryByCondition() {
    var param = {};
    $('#equipeMentTable').bootstrapTable('refreshOptions', {
      queryParams: function (params) {
          var obj = {
            size: params.limit,
            page: params.offset / params.limit + 1,
          };
          $.extend(param, obj);
          return JSON.stringify(param);
      }
    });
};

/**
 * 表格初始化
 */
function initTable(newParams) {
  var $table = $('#equipeMentTable');
  $table.bootstrapTable({
    url: "",
    method: 'POST',
    pagination: true,
    pageSize: 10,
    sidePagination: 'server',//设置为服务器端分页
    queryParams: function (params) {
      // 请求参数
      var obj = {
        size: params.limit,
        page: params.offset / params.limit + 1
      };
      return JSON.stringify(obj);
    }
  });
};

$(document).ready(function() {
    var $table = $('#equipeMentTable');
    $table.bootstrapTable({
      data: data,
      pagination: true
    });
});
